package gsb.gsb;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import java.util.List;
import modele.Medecin;

public class MedAdapter extends BaseAdapter{
    private List<Medecin> lesMeds;
    private Context c;
    MedAdapter(List data, Context c){
        lesMeds = data;
        this.c = c;
    }
    public int getCount(){
        return lesMeds.size();
    }
    public Object getItem(int i){
        return lesMeds.get(i);
    }
    public long getItemId(int i){
        return i;
    }
    public View getView(int i, View v, ViewGroup vg){
        //creation de la vue en analysant le xml lignemed
        LayoutInflater vi = (LayoutInflater)c.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        v = vi.inflate(R.layout.lignemed, null);
        TextView nom = (TextView) v.findViewById(R.id.nom);
        TextView prenom = (TextView) v.findViewById(R.id.prenom);
        TextView adresse = (TextView) v.findViewById(R.id.adresse);
        TextView spe = (TextView) v.findViewById(R.id.spe);
        TextView tel = (TextView) v.findViewById(R.id.tel);
        Medecin leMed = lesMeds.get(i);
        nom.setText(leMed.getNom());
        prenom.setText(leMed.getPrenom());
        adresse.setText(leMed.getAdresse());
        spe.setText(leMed.getTel());
        tel.setText(leMed.getSpe());
        return v;
    }
}
